Skip to content

feat(lab): run a lab in governed mode and approve tool calls from portal dev - #1355

Merged
Rotfuks merged 9 commits into
mainfrom
tool-approval
Dec 2, 2026
Merged

Rotfuks merged 9 commits into
mainfrom
tool-approval

Conversation

@Rotfuks

@Rotfuks Rotfuks commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Part of giantswarm/giantswarm#38902. The review record is the first comment on this PR, with an update comment for the code added later.

What does this PR do?

Adds "Running a lab in governed mode" to docs/platform.md. The agent-platform chart's governance.mode value (trusted, the default, or governed) decides whether muster also asks a person before an agent runs a write on the platform's own servers. The section shows how to set it in a lab with a platform.valuesFiles overlay (governance: {mode: governed}), that agentlab status names the overlay and the mode, that muster reads the mode once at start so the run rolls muster, and how to go back to trusted. It also names what a dev chart needs before releases carry tool approval (floors that name dev builds, the OAuth server and muster.muster.oauth.mcpClient.publicUrl on the lab's edge, backstage.publicPort for a portal not on 443).

One file, docs/platform.md, +41 in the first three commits (88cca0b, 5e5a267, 535bb76; governance is a map).

After that the branch also makes the lab run tool approval's sign-in handoff and inline approval:

Commit What
0e627e4 (superseded by main's backstage client, #1392, in the merge 8d22ec9) Dex client agent-platform-portal (the portal's callbacks only), trusted peers on agent-platform, kubernetes and dex-k8s-authenticator, its secret in agent-platform-secrets (portal-dex-client-secret); the lab values set backstage.oidcClientId; portal dev passes the secret; docs/identity.md
5ff5c11 portal dev admits the hot-reload portal's /sessions on muster's return allowlist
5e61903 portal dev mints the portal's workload token (audience muster, a file, 0600) for muster's inline approval; muster.workloadTokenFile in the dev app config
77b47c7 docs condensed
a2ce1be test only: the repeated "muster" literal in portalclient_test.go flagged by goconst in CI
8d22ec9 merge of main: main's dedicated portal client backstage (#1392) replaces agent-platform-portal, so portalclient.go, the second Dex client and its secret key are gone; portal dev passes the backstage client's secret (portal-dex-client-secret)

Tip 8d22ec9.

What is the effect of this change to users?

People running the lab find how to try governed mode. portal dev gets what the in-cluster portal already has on main (its own backstage client, #1392): the client's secret, the workload token and muster's return allowlist, so the hot-reload portal can use the handoff and decide approvals inline. Labs on a chart without those values are unchanged.

What does it look like?

Docs for governed mode; code and docs for the portal's client and token (see above).

Any background context you can provide?

Epic giantswarm/giantswarm#38902. The agent-platform chart wires the client (backstage.oidcClientId, muster.trustedClientsFloor); muster and the portal consume the token (linked below). Links the concept page "Governing tool calls" as optional further reading.

What is needed from the reviewers?

Check that the overlay example and the steps match the current agentlab platform behaviour; check the Dex client's scope (portal callbacks only) and that the workload token file is not committed or logged. Known: in the lab the password connector and a constant client secret mean a password grant can mint portal-client tokens (docs wording to fix, LC-12 in the update record); the workload token is still needed to decide.

Do the docs need to be updated?

This is the docs change.

Testing

The overlay mechanism (platform.valuesFiles, platform.chartPath, platform.devImages, components.<name>.versionRange) is the one the milestone 2 and 3 lab runs used on 2026-11-26 (bring-up, agentlab platform exit 0, platform-test passed in both runs). The governed-mode overlay itself ran in the M2 lab (governed mode: floors, exceptions and governed Ask checked). Later (2026-11-26): TestDexTemplateRegistersThePortalClient and the config and lab render subsets (go test ./internal/config ./internal/lab, portal, Dex, workload token) pass; the lab ran with the new binary through the handoff, inline approval and a final rollout (the portal signs in with its own client, the token carries azp agent-platform-portal, the portal backend's workload token works against muster, platform-test exit 0). Known failures in internal/lab on macOS (measure, browser, git-pause, session-directory) are the same at the fork point; golangci-lint reports only the darwin internal/shaper unused findings. Not run: the full suite on another platform.

Changes from the plan

Where this PR differs from the design in the epic (giantswarm/giantswarm#38902):

  • Portal client. The design has the portal act with the shared platform client. The lab gives the portal its own Dex client, because muster now trusts only that client for sign-in tickets and inline decisions.
  • Dev portal. portal dev admits /sessions on muster's return allowlist and mints the portal's workload token, so the hot-reload portal can use the handoff and decide inline like the in-cluster one.
  • Scope. The design lists agentlab for documentation only; this branch also carries the Dex template, the lab values and the portal dev changes above.

Related pull requests

Repository PR Role
muster giantswarm/muster#1912 enforcement, approval page, governance, agent settings and grants
backstage giantswarm/backstage#3655 portal: connector and agent tool settings, session prompt, inline approval card
klaus-gateway giantswarm/klaus-gateway#618 Slack prompt and return
agent-platform giantswarm/agent-platform#1495 governance value, safe lists, wiring, agent chart 3.x guard and migrate preflight, the portal's own client and trusted-client wiring
agent-manager giantswarm/agent-manager#483 chart default, per-agent approval settings and grants, migrate 2.x to 3.x
model-manager giantswarm/model-manager#462 chart default
vm-manager giantswarm/vm-manager#264 chart default
cluster-manager giantswarm/cluster-manager#359 chart default
workspace-manager giantswarm/workspace-manager#229 chart default
toolchain-manager giantswarm/toolchain-manager#100 chart default
skill-manager giantswarm/skill-manager#48 chart default
agent-platform-mcps giantswarm/agent-platform-mcps#108 chart defaults for the families
agent giantswarm/agent#143 agent chart 3.0: tools and default, requireApproval removed
agent-skills giantswarm/agent-skills#90 agent management skill
agent-platform-operator giantswarm/agent-platform-operator#74 organization chart source follows the configuration
giantswarm-platform-manager giantswarm/giantswarm-platform-manager#1053 governance as a typed input, second-person review

This was referenced Nov 26, 2026
@Rotfuks

Rotfuks commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Review record

Part of giantswarm/giantswarm#38902 (tool approval). Purpose: this repository has documentation changes only and no review of its own. This record states what was checked and which review covered it. Branch tool-approval is 3 commits on a00ff7a (88cca0b, 5e5a267, 535bb76; docs/platform.md, +41 lines): a new section "Running a lab in governed mode". Hashes are those of the pushed tool-approval branch.

Read this first

  • No code changed. The section documents the platform chart's governance.mode value, the overlay that sets it, why a chart without release floors refuses governed, and how to run a lab with a dev chart and dev component charts.
  • Covered by an OSS-neutrality audit of the added lines and a spot-check at the tip. The text itself was not executed as written; the documented route (a platform.valuesFiles overlay, platform.chartPath, dev component charts through components.<name>.versionRange) is the one used in the four tool-approval lab runs, which switched governance between trusted and governed with agentlab platform.
  • Not verified: the sentence that agentlab status names the overlay and the mode it sets.

Review rounds

# Round Scope Reviewer Kind Result
1 OSS-neutrality audit added lines read-only audit audit 2 findings: a vendor docs link for governed mode; a section that reads like a contributor note (dev-build workflow)
2 Fix 5e5a267, 535bb76 implementer fix the link is optional further reading; governance is described as a map with governance.mode
3 Spot-check tip 535bb76 Claude Fable 5.2, independent docs one optional docs link, nothing else
4 Delta review, charts and portal no commit after 535bb76; the text of 535bb76 read Claude Sonnet 5.5, independent docs no finding

Findings

ID Severity Title Outcome
OSS-A1 docs link to a vendor docs page as the reference for governed mode fixed in 5e5a267: optional further reading
OSS-A2 docs dev-build workflow in a user-facing section accepted: valid for any lab, no vendor-only step; it is a contributor workflow

Lab verification

The agentlab binary itself was not changed. It ran all four tool-approval lab runs (bring-up, platform-test, overlays, dev images). A separate lab limitation found in the process (agent-manager 3.5 refuses a loopback issuer; agentlab's bring-your-own-certificate mode avoids it) is tracked in agentlab's own issue tracker and is not part of this branch.

Open items

Findings still open or partly fixed:

Item Severity What remains Why it is acceptable now
OSS-A2 docs the dev-build workflow sits in a user-facing section accepted: valid for any lab, no vendor-only step; it is a contributor workflow
Floors the section says a chart without release floors refuses governed; this stays true until the platform chart pins the real releases documented as a transitional state

Never run:

  • The overlay steps verbatim from the page, and a fresh lab bring-up following only this page; the sentence that agentlab status names the overlay and the mode it sets was not verified.
  • A lab with a remote target (gitops.target.kubeConfig), Flux's remediation of failing organization upgrades, a real Slack, a browser, helm unittest.

…in handoff

The portal signed in with agent-platform, the client every CLI helper and
proof shares, so muster could not trust the portal for the one-time sign-in
handoff without trusting them all. The lab Dex now registers
agent-platform-portal with the portal's callbacks only; agent-platform,
kubernetes and dex-k8s-authenticator list it under trustedPeers, so its
tokens keep every audience consumers accept. Where the platform chart takes
backstage.oidcClientId the lab sets it, which makes the chart list that
client in muster's approval.handoffClients. The secret is the key
portal-dex-client-secret of agent-platform-secrets (added to an existing
Secret), and portal dev passes it as AGENT_PLATFORM_PORTAL_OIDC_CLIENT_SECRET.
… return allowlist

While backstage.localDevPort is set the lab renders
muster.oauth.mcpClient.postLoginRedirectAllowlist with
http://localhost:3000/sessions, so the approval page returns the browser to
agentlab portal dev instead of showing its own answer page. Lab only.
…nline approval

muster takes the portal's inline approval decisions and sign-in handoff
requests only with the portal backend's own ServiceAccount token
(audience muster) beside the person's. The hot-reload portal has no
projected token, so every `agentlab portal dev` mints one for the lab
portal's ServiceAccount (agent-platform/backstage, TokenRequest, 12h),
writes it to state/backstage-dev/muster-workload-token (0600) and points
the backend's muster.workloadTokenFile at it. Without that
ServiceAccount it says so and approvals open muster's own pages.
@Rotfuks

Rotfuks commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Review record — update

Part of giantswarm/giantswarm#38902. Covers only what is new since the record above (tip 535bb76). The branch now carries code, not only documentation: the lab can give the portal its own Dex client and mint the portal's workload token. Branch tool-approval is now 8 commits on a00ff7a, tip a2ce1be. 5 commits since: 0e627e4, 5ff5c11, 5e61903, 77b47c7, a2ce1be.

Read this first

  • New since the record: a Dex client agent-platform-portal for the portal's callbacks only, trusted peers on agent-platform, kubernetes and dex-k8s-authenticator, its secret in agent-platform-secrets, the lab values set the portal's client (0e627e4); portal dev admits the hot-reload portal's /sessions on muster's return allowlist (5ff5c11); portal dev mints the workload token for muster's inline approval (5e61903); docs condensed (77b47c7).
  • Independently reviewed (Claude Fable 5.2, read by a fork of the review session): 5e61903 and the config and lab render subsets in the last check. 0 critical, 0 high.
  • Not independently re-checked: 77b47c7 (docs only) and a2ce1be (test only: a literal in portalclient_test.go that goconst flagged in CI; golangci-lint clean on internal/lab afterwards).
  • Not run by anyone: the full internal/lab suite on a platform other than the implementer's (known macOS failures in measure, browser, git-pause and session-directory tests are unchanged and not from these commits), golangci-lint beyond the implementer's run (only the darwin internal/shaper unused findings, not from this branch).

Review rounds

# Round Scope Reviewer Kind Result
5 Lab: handoff, inline approval, final rollout binary at 0e627e4, then 5e61903 tester lab the portal signs in with its own client; the token carries azp agent-platform-portal; the portal backend's workload token works against the lab's muster; platform-test exit 0 after each rollout
6 Last check 535bb76..5e61903; go test ./internal/config ./internal/lab (portal, Dex, workload token, render subsets) pass; 6 mutants (4 killed, 2 survived) Claude Fable 5.2, independent (fork) code and security 0 critical, 0 high; LC-12 (minor [sec]), LC-15 (nit)
7 Docs 77b47c7 implementer docs condensed
8 CI fix a2ce1be implementer fix goconst finding in a test (no behaviour change)

Open items

ID Severity What is open
LC-12 minor [sec] docs/identity.md says no CLI helper or proof can sign in with the portal's client. Not true in the lab: Dex has the password connector on and the client's secret is a constant in the repository, so a password grant gives azp = portal tokens for the static lab users. Lab only, and the workload token is still needed to decide. Wording to change
LC-15 nit Two surviving mutants without a test: the ServiceAccount name, the empty-token check
LC-16 nit The values template comment still names approval.handoffClients (renamed trustedClients)

@Rotfuks Rotfuks changed the title docs: describe running a lab in governed mode feat(lab): run a lab in governed mode with the portal's own sign-in client and workload token Nov 26, 2026
@QuentinBisson

Copy link
Copy Markdown
Contributor

Review supplement for giantswarm/giantswarm#38902

Reviewed head: a2ce1be902dc7ae157a15259d48aa89f1f2963f8 (rechecked unchanged). Compared the epic, linked PRD and subsequent design decisions with the implementation and existing local review record. Focus: dedicated portal OAuth client, chart capability detection, local workload-token minting/overlay and documentation. This supplements those reviews; it does not claim to rerun their tests or independently verify every generated fixture/test assertion.

Spec

The lab supplies the separate portal client and workload credential required by the reviewed muster/portal interface. It is development support, not production enforcement proof.

This is a scoped contract assessment, not an exhaustive numbered acceptance score. Independent focused specification cross-checks covered the core enforcement/client contracts and platform/manager integration. Declared follow-ups and accepted design changes are not counted as new defects.

Blocking

No new blocking code finding established in this pass.

Non-blocking

None newly established.

Suggestions

None beyond the existing review follow-ups.

Deep verification

Aspect Status Evidence / limit
Problem confirmed on base n/a: feature slice The diff introduces the approval-related contract reviewed here; no claim of a locally reproduced base failure.
Fix addresses named root cause covers inspected scope Relevant changed paths traced against the scoped requirement.
Spec criteria met qualitative; no exhaustive score See Spec above.
Tests pin the contract static evidence Portal client detection, overlay and TokenRequest assertions inspected; live local portal flow unverified.
Correct (edge cases) no additional defect established Inspected changed contracts and cross-repository dependencies; not a proof of all interleavings.
Standard mechanism existing patterns used Kubernetes TokenRequest and existing lab file/overlay conventions; OAuth client/audience terminology.
Standard names sourced MCP/Kubernetes identifiers and PRD terminology; no new naming finding.
Security boundaries static review only Dedicated client and audience-scoped portal ServiceAccount token inspected; lab credential handling only.
Simplest fix retain approach Reuse the chart's portal identity and existing local development flow.
Reuse check no new duplication finding Existing surrounding helpers/patterns inspected within the stated scope.
CI checks green reported checks / skips See CI note below.
Pipeline gates unverified locally PR code execution prohibited in this session.
Findings 0 blocking / 0 non-blocking / 0 suggestions Findings above supplement the existing review record.
Merge danger two-way door local lab login and approval development.

Reported checks passed or were skipped; no failed/cancelled check to triage. A skipped job is not evidence that its gate ran.

Unverified locally: applicable builds, tests (including race/integration/envtest), vet, formatting/lint/pre-commit, generators, Makefile verification targets, Helm rendering/schema/unit checks, and browser/live-cluster flows. No PR code was executed. GitHub-reported CI provides supporting evidence, not a local reproduction.

Recommendation: merge as-is within this review's scope, subject to existing release-order/rollout prerequisites and previously documented open items.

Team context: none.

@Rotfuks
Rotfuks marked this pull request as ready for review November 30, 2026 08:36
@Rotfuks
Rotfuks requested a review from a team as a code owner November 30, 2026 08:36
main's dedicated portal client (backstage, #1392) replaces this branch's
agent-platform-portal client; the branch keeps the local portal dev's
workload token, client secret and return allowlist.
@Rotfuks Rotfuks changed the title feat(lab): run a lab in governed mode with the portal's own sign-in client and workload token feat(lab): run a lab in governed mode and approve tool calls from portal dev Dec 2, 2026
@Rotfuks
Rotfuks merged commit 0805c4a into main Dec 2, 2026
9 checks passed
@Rotfuks
Rotfuks deleted the tool-approval branch December 2, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants